<template>
	<view class="mm-tag">
		<view class="mm-tag__content" :style="{backgroundColor: realColor}">
			<slot></slot>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			// 标签背景色，支持接收主题色
			color: {
				type: String,
				default: 'primary'
			}
		},
		computed: {
			realColor() {
				return this.$theme[this.color] || this.color;
			}
		}
	}
</script>

<style lang="scss" scoped>
	// 由于微信小程序高度在40rpx以下会莫名多出一点空隙，所以默认组件最小高度40rpx
	.mm-tag {
		vertical-align: top;
		line-height: 40rpx;
		height: 40rpx;
		margin-left: 20rpx;
		display: inline-flex;
		padding-top: 6rpx;
		&__content {
			padding: 0 10rpx;
			font-size: 22rpx;
			color: #fff;
			border-radius: 4rpx;
			height: 30rpx;
			line-height: 30rpx;
		}
	}
</style>
